using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;

namespace Netduino4Fun.Framework
{
    public class Motor
    {
        public Cpu.Pin EnablePin { get; private set; }
        public Cpu.Pin DirectionPin { get; private set; }

        private PWM DirectionOutput { get; set; }
        private OutputPort EnableOutput { get; set; }

        public Motor(Cpu.Pin enable,Cpu.Pin direction)
        {
            this.EnablePin = enable;
            this.DirectionPin = direction;
            this.EnableOutput = new OutputPort(enable,false);
            this.DirectionOutput = new PWM(direction);
        }

        public void Start(uint speed)
        {
            this.EnableOutput.Write(true);
            this.DirectionOutput.SetDutyCycle(speed);
        }

        public void Stop()
        {
            this.EnableOutput.Write(false);
            this.DirectionOutput.SetDutyCycle(0);
        }
    }
}
